﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.IO;
using System.Threading;

namespace ATM
{
    public partial class currencyToPound : Form
    {
        CurrencyTranLogic lo = new CurrencyTranLogic();
        public string mony, CList;
        string accNum;
        public currencyToPound(string acc)
        {
            InitializeComponent();
            accNum = acc;
        }

        private void exitButt_Click(object sender, EventArgs e)
        {
            welcom w = new welcom();
            w.Show();
            this.Hide();
        }

        private void backButt_Click(object sender, EventArgs e)
        {
            CurrencyTransIntro inter = new CurrencyTransIntro(accNum);
            inter.Show();
            this.Hide();
        }
        private void numbers_buttons(object sender, EventArgs e)
        {
            Button b = (Button)sender;
            currencycount.Text = currencycount.Text + b.Text;
        }

        private void calculateButt_Click(object sender, EventArgs e)
        {
            mony = currencycount.Text;
            CList = currencyList.Text;
            
                lo.calculate_call(CList, mony);
                
                if (lo.checkEmtpy == 0)
                    MessageBox.Show("Please select currency type and number of it to calculate");
                else
                {
                    if (lo.checkWrong == 1)
                    {
                        show_pounds.Text = lo.calculate.ToString();
                        display_show();
                    }
                    else
                    {
                        MessageBox.Show("Please Enter a valid numbers !");
                        currencycount.Text = "";
                    }
                }
                
        }

        private void bcash_Click(object sender, EventArgs e)
        {
            
            inter_face inter = new inter_face(accNum);
            inter.Show();
            this.Hide();
            MessageBox.Show("Your mony is coming out shortly");
        }

        private void b_balance_Click(object sender, EventArgs e)
        {
            lo.add_t_balnce(accNum);
            inter_face inter = new inter_face(accNum);
            inter.Show();
            this.Hide();

         
        }

        void display_show()
        {

            int height = 249;
            while (height <= 329)
            {
                this.Size = new Size(520, height);
                this.Refresh();
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                this.SetStyle(ControlStyles.UserPaint, true);
                Thread.Sleep(10);
                height += 10;
            }
        }

        private void form_Load(object sender, EventArgs e)
        {
            this.Size = new Size(520, 249);
        }

        private void clear_Click(object sender, EventArgs e)
        {
            currencycount.Text = "";
        }
    }
}
